<template>
  <div class="content_strategy">
    <div>
      <el-button size="mini" plain @click="openSelectstrategyList('1')"
        >+文章</el-button
      >
      <el-button size="mini" plain @click="openSelectstrategyList('4')"
        >+海报</el-button
      >
      <el-button size="mini" plain @click="openSelectstrategyList('2')"
        >+线上活动</el-button
      >
      <el-button size="mini" plain @click="openSelectstrategyList('3')"
        >+线下活动</el-button
      >
    </div>
    <div class="info">
      <div>名称：{{ ruleForm.activityData.name }}</div>
      <div>类型：{{ ruleForm.activityData.typeName }}</div>
      <div>渠道：{{ ruleForm.activityData.channel }}</div>
      <div>机构：{{ ruleForm.activityData.orgcode }}</div>
      <div>说明：{{ ruleForm.activityData.remark }}</div>
    </div>
    <strategyList
      v-if="showSelectPop"
      :selectType="selectType"
      :showSelectListPop="showSelectPop"
      :activityData="activityData"
      @changeShowSelectPop="changeShowSelectPop"
    ></strategyList>
  </div>
</template>
<script>
import strategyList from "./strategyList.vue";

export default {
  name: "contentStrategy",
  components: { strategyList },
  props: ["activityData"],
  data() {
    return {
      showSelectPop: false,
      ruleForm: {
        activityData: {},
        activityName: "",
      },
      selectType: "",
      operationType: "",
    };
  },
  watch: {
    activityData: {
      handler(newVal) {
        this.ruleForm.activityData = newVal || {};
      },
      immediate: true,
    },
  },
  mounted() {
    this.operationType = this.$route.query.type;
  },
  methods: {
    openSelectstrategyList(type) {
      if (this.operationType == "check") {
        return;
      }
      this.selectType = type;
      console.log("openSelectstrategyList", this.activityData);
      this.showSelectPop = true;
    },
    changeShowSelectPop(data) {
      console.log("changeShowSelectPop", data);
      if (data) {
        this.ruleForm.activityData = data;
        this.ruleForm.activityName = data.name;
        this.$emit("getActivityData", data);
      }
      this.showSelectPop = false;
    },
  },
};
</script>
<style lang="less" scoped>
.content_strategy {
  margin-top: 10px;
  .info {
    padding: 10px;
    font-size: 14px;
    margin: 10px 0;
    border: 1px solid #c7c7c7;
  }
}
</style>
